package enumandlambda;

/**
 * @author shkstart
 * 判断线程是否存活
 * @create 2022-12-01-11:25
 */
public class ThreadDemoByAlive {
    public static void main(String[] args) throws InterruptedException {
        Thread t= new Thread(()->{
            for (int i = 0; i < 10; i++) {

                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("1.线程执行完了 ");
        });
        t.start();
        while (t.isAlive()){

        }
        System.out.println("2: 确认线程执行完了");


    }
}
